package algocasts;

public class P81_reverseString {
    // Time:O(n)  Space:O(n)
    public String reverseString(String s) {
        if (s == null) return null;
        char[] chars = s.toCharArray();
        for (int i = 0, j = chars.length - 1; i < j; i++, j--) {
            char c = chars[i];
            chars[i] = chars[j];
            chars[j] = c;
        }
        return new String(chars);
    }
}
